package com.example.cheng.mapper;

import com.example.cheng.poji.*;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

@Mapper
public interface UserMapper {
//    店铺列表
    @Select("select * from chengData.storelist order by create_time desc")
    public List<StoreListDtoOut> getStoreList();

    @Select("select name from chengData.storelist where id=#{id}")
    public String getStoreName(String id);

    @Select("select discount from chengData.storelist where id=#{id}")
    public String getStorePercent(String id);
    @Insert("insert into storelist (name,discount) values (#{name},#{discount})")
    public void addStoreAtion(StoreListDtoIn dtoIn);

    @Update("update chengData.storelist set name= #{name},discount = #{discount},update_time = #{update_time} where id = #{id}")
    public void updateStore(StoreListDtoIn dtoIn);

    @Delete("DELETE from chengData.storelist where id=#{id}")
    public void deleteStore(StoreListDtoIn dtoIn);

//    添加员工

    @Insert("insert into users (name,phone,password,sid,role) values (#{name},#{phone},#{password},#{sid},#{role})")
    public void addUserAtion(UserAddDtoIn dtoIn);

    @Select("select * from chengData.users order by create_time desc")
    public List<UserAddDtoOut> getUserList();

    @Select("select * from chengData.users where phone=#{phone}")
    public UserAddDtoOut getUser(String phone);


    @Select("select * from chengData.users where id=#{id}")
    public UserAddDtoOut getUserById(String id);
    @Delete("DELETE from chengData.users where id=#{id}")
    public void deleteUser(UserAddDtoOut dtoIn);

    //    登录
    @Select("select * from chengData.users where phone=#{phone} and password=#{password}")
    public List<UserAddDtoOut> login(UserAddDtoIn dtoIn);

    @Select("select name from chengData.users where id=#{id}")
    public String getUserName(String id);
//    商品


    @Select("select * from chengData.goods where name like concat('%',#{query},'%') order by create_time desc")
    public List<GoodsListDtoOut> getGoodsList(GoodsAddDtoIn dtoIn);

    @Select("select * from chengData.goods where id=#{id}")
    public GoodsListDtoOut getGoodInformation(String id);

    @Insert("insert into chengData.goods (name,price,nprice,type,image) values (#{name},#{price},#{nprice},#{type},#{image})")
    public void addGoodsAtion(GoodsAddDtoIn dtoIn);

    @Update("update chengData.goods set name= #{name},price = #{price},nprice = #{nprice},type = #{type},image = #{image}, use_type = #{use_type},update_time = #{update_time} where id = #{id}")
    public void updateGoods(GoodsListDtoOut dtoIn);

    @Delete("DELETE from chengData.goods where id=#{id}")
    public void deleteGoods(GoodsListDtoOut dtoIn);

    @Update("update chengData.goods set xiajia = #{xiajia},update_time = #{update_time} where id = #{id}")
    public void xiajiaGoods(GoodsListDtoOut dtoIn);

    //    档位
    @Select("select * from chengData.dangweis where name like concat('%',#{query},'%')  order by create_time desc")
    public List<DangweiDtoOut> getDangweiList(DangweiSearchDtoIn dtoin);

    @Insert("insert into chengData.dangweis (name,price) values (#{name},#{price})")
    public void addDangweiAtion(DangweiAddDtoIn dtoIn);

    @Update("update chengData.dangweis set name= #{name},price = #{price},use_type = #{use_type},update_time = #{update_time} where id = #{id}")
    public void updateDangwei(DangweiDtoOut dtoIn);

    @Delete("DELETE from chengData.dangweis where id=#{id}")
    public void deleteDangwei(DangweiDtoOut dtoIn);

    @Select("select * from chengData.dangweis where id=#{id}")
    public DangweiDtoOut getDangweiItem(String id);

//    订单
    @Insert("insert into chengData.orders (sid,did,uid,goods,yname,yphone,address,bprice,xprice,number) values (#{sid},#{did},#{uid},#{goods},#{yname},#{yphone},#{address},#{bprice},#{xprice},#{number})")
    public void addOrderAtion(OrderAddDtoIn dtoIn);


//    @Select("select * from chengData.orders where uid=#{uid} and create_time >= #{start_time} and create_time <= #{end_time} order by create_time desc")
    public List<OrderListDtoOut> getOrdersList(OrderSearchDtoIn dto);

    @Select("select * from chengData.orders where id=#{id}")
    public OrderListDtoOut getOrderById(String id);
    @Select("select * from chengData.orders where sid=#{id}")
    public OrderListDtoOut getOrderBySId(String id);
    @Delete("DELETE from chengData.orders where id=#{id}")
    public void deleteOrder(OrderListDtoOut dtoIn);

    @Update("update chengData.orders set knumber= #{knumber},status=#{status},update_time = #{update_time} where id = #{id}")
    public void updateOrder(OrderListDtoOut dtoIn);
//    sid,did,uid,goods,yname,yphone,address,bprice,xprice,number
    @Update("update chengData.orders set sid= #{sid},did=#{did},uid = #{uid} ,goods = #{goods},yname = #{yname},yphone = #{yphone},address = #{address},bprice = #{bprice},xprice = #{xprice} where id = #{id}")
    public void xiugaiOrder(OrderListDtoOut dtoIn);

//    设备
    @Insert("insert into chengData.device_type (name) values (#{name})")
    public void addDeviceAction(DeviceAddDtoIn dtoIn);

    @Select("select name from chengData.device_type where id=#{id}")
    public String getDeviceName(String id);
    @Select("select * from chengData.device_type order by create_time desc")
    public List<DeviceListDtoOut> getDevices();

    @Delete("DELETE from chengData.device_type where id=#{id}")
    public void deleteDevice(DeviceListDtoOut dto);

    @Update("update chengData.device_type set xiajia= #{xiajia} where id = #{id}")
    public void updateDeviceXiajia(DeviceListDtoOut dtoIn);
    @Update("update chengData.device_type set use_type= #{use_type} where id = #{id}")
    public void updateDeviceUseType(DeviceListDtoOut dtoIn);
    @Update("update chengData.device_type set name= #{name},update_time = #{update_time} where id = #{id}")
    public void updateDevice(DeviceListDtoOut dtoIn);



    @Insert("insert into chengData.devices (name,fid) values (#{name},#{fid})")
    public void addDeviceClassAction(DeviceClassAddDtoIn dtoIn);

    @Update("update chengData.devices set use_type= #{use_type} where id = #{id}")
    public void updateDeviceClass(DeviceClassListDtoOut dtoIn);

    @Update("update chengData.devices set name= #{name} where id = #{id}")
    public void updateDeviceName(DeviceClassListDtoOut dtoIn);

    @Update("update chengData.devices set xiajia= #{xiajia} where id = #{id}")
    public void updateDeviceClassXiajia(DeviceClassListDtoOut dtoIn);

    @Delete("DELETE from chengData.devices where id=#{id}")
    public void deleteDeviceClass(DeviceClassListDtoOut dto);


    @Select("select name from chengData.devices where id=#{id}")
    public String getDeviceFName(String id);

    @Select("select * from chengData.devices order by create_time desc")
    public List<DeviceClassListDtoOut> getDeviceClass();

    @Select("select * from chengData.devices where fid=#{id} order by create_time desc")
    public List<DeviceClassListDtoOut> getDeviceClassById(DeviceClassListDtoOut dtoin);

//  入库
    @Insert("insert into chengData.inventorys (sid,uid,yid,fid,number,image,rremark) values (#{sid},#{uid},#{yid},#{fid},#{number},#{image},#{rremark})")
    public void inventorysAddAction(InventorysAddDtoIn dtoIn);

    @Update("update chengData.inventorys set sid= #{sid},uid = #{uid},yid = #{yid},fid = #{fid},number = #{number} ,image = #{image} ,rremark = #{rremark}where id = #{id}")
    public void changeKuDataAction(InventorysListDtoOut dtoIn);
//    @Select("select * from chengData.inventorys order by create_time desc")
    public List<InventorysListDtoOut> getInventorysAction(InventorysSearchDtoIn dtoIn);

    @Update("update chengData.inventorys set cname= #{cname},account = #{account},remark = #{remark},cimage = #{cimage},idCard = #{idCard},update_time = #{update_time} ,status = #{status} where id = #{id}")
    public void chukuAction(InventorysListDtoOut dtoIn);

    @Delete("DELETE from chengData.inventorys where id=#{id}")
    public void deleteinventoryItem(InventorysListDtoOut dto);

    @Select("select * from chengData.inventorys where id=#{id}")
    public InventorysListDtoOut getDeviceById(String id);
}
